# -*- coding: utf-8 -*-


'''
@author: José Gorgulho 5622
@date: 10/29/2012
@obs
Main module for the first Programming Languages Class work
'''

from xlsp import xls_handler
from sqlitep import sqlite_handler

xls_book = xls_handler('Inscritos_2010-2011')
test = xls_book.open_book()
if( test!=False ):
    test = xls_book.select_book_sheet('Tabela 4.1')
    if( test !=False ):
        xls_book.get_lists()
    else:
        print xls_book.error_message
else:
    print xls_book.error_message
    
course = xls_book.course
degree = xls_book.degree
faculty = xls_book.faculty
school = xls_book.school

course_x = len(course)-1
degree_x = course[course_x][2]
faculty_x = degree[course[course_x][2]][2]
school_x = school[faculty[faculty_x][2]][1]

database = sqlite_handler('inscritos')
test = database.open_database()
if(test != False):
    test = database.create_table('schools')
    if(test !=False):
        test = database.add_to_table('schools', school)
        if(test !=False):
            pass
        else:
            print database.error_message
    else:
        print database.error_message
else:
        print database.error_message
print '\n\n############ end main program ############\n\n'

